/*
 * Part of the ACID Project
 * Developed in 2011 by Morgan Taschuk
 */
package acid.network;

import cytoscape.CyEdge;
import cytoscape.CyNode;
import cytoscape.Cytoscape;
import cytoscape.data.CyAttributes;
import edu.asu.emit.qyan.alg.model.Graph;
import java.util.List;

/**
 *
 * @author morgan
 */
public class ParseCytoscapeGraph
{

    private ParseCytoscapeGraph()
    {
    }

    public static Graph getAcidGraph(String edgeWeightName)
    {
        AcidGraph graph = new AcidGraph();
        List nodes = Cytoscape.getCyNodesList();
        List edges = Cytoscape.getCyEdgesList();

        for (Object n : nodes)
        {
            CyNode node = (CyNode) n;
            graph.addNode(new Integer(node.getIdentifier()));
        }
        for (Object e : edges)
        {
            CyEdge edge = (CyEdge) e;
            CyAttributes edgeAttributes = Cytoscape.getEdgeAttributes();
            double weight = 1;//edgeAttributes.getDoubleAttribute(edge.getIdentifier(), edgeWeightName);
            int s = new Integer(edge.getSource().getIdentifier());
            int t = new Integer(edge.getTarget().getIdentifier());
            if (s!=t)
                graph.addEdge(s, t, weight);
        }
        return graph;
    }
}
